package test.nodes;

import bgai.ai.minimax.Board;
import bgai.ai.minimax.Evaluator;

public class MyEval implements Evaluator {
	
	private static final double bestThreshold= 5;
	private static final double goodThreshold= 0;

	@Override
	public double evaluate(Board board, boolean thisIsMaxNode) {
		Node node= (Node) board;
		
		return node.value();
	}

	@Override
	public double upperBound() {
		return 10;
	}

	@Override
	public double lowerBound() {
		return -10;
	}

	@Override
	public boolean hasBestQuality(Board board, boolean isMaxNode) {
		double score= evaluate(board, isMaxNode);
		if (isMaxNode) {
			// massimizzo
			if (score>=bestThreshold) return true;
			else return false;
		} else {
			// minimizzo
			if (score<=-bestThreshold) return true;
			else return false;
		}
	}

	@Override
	public boolean hasGoodQuality(Board board, boolean isMaxNode) {
		double score= evaluate(board, isMaxNode);
		if (isMaxNode) {
			// massimizzo
			if (score>=goodThreshold) return true;
			else return false;
		} else {
			// minimizzo
			if (score<=-goodThreshold) return true;
			else return false;
		}
	}

}
